from plot.die import Die
import pygal

die_1 = Die()
die_2 = Die()

results = []
for num in range(1000):
    roll_num = die_1.roll() + die_2.roll()
    results.append(roll_num)

frequencies = []
max_sides = die_1.num_sides + die_2.num_sides + 1
for num in range(1, max_sides):
    frequency = results.count(num)
    frequencies.append(frequency)

bar_chart = pygal.Bar()
bar_chart.x_labels = range(1, max_sides)
bar_chart._x_title = "骰子之和"
bar_chart._y_title = "出现频率"
bar_chart._title = "1000次两个骰子和出现频率直方图"

bar_chart.add("D6+D6", frequencies)
bar_chart.render_to_file("dice_visual.svg")
